<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.ArrayList,
                 com.scalar.chiptrack.utils.ConfigManager,
                 org.apache.struts.util.LabelValueBean,
                 com.scalar.forecast.commons.SessionKeys,
                 com.scalar.forecast.commons.Constants"%>

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<chiptrack:checkLogon sourcePage="/salesPersonSetup.do"/>

<html:html locale="true">

<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>

<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>
<% User user1 = (User) session.getAttribute (SessionKeys.USER_KEY); %>

<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>

<META content="MSHTML 5.50.4807.2300" name=GENERATOR></HEAD>
<BODY bgColor="#ffffff" leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">
<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js">
</script>
<SCRIPT language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/validations.js">
</script>
<SCRIPT language="JavaScript">

function saveSystemPreferences()
{
    var form    = document.systemPreferencesForm;
    var pa   = document.getElementById ( 'errorsId' );
    var freezingPointCtrl = form['forecastTimeFrame.tfCompany'];
    var errors = "";
    var tfCycle = form['forecastTimeFrame.tfCycle'].value;
    var freezingPointLimit = 7;
    if( tfCycle == 'weekly' ) {
        freezingPointLimit = 7;
    } else if ( tfCycle == 'monthly' ) {
        freezingPointLimit = 30;
    } else if ( tfCycle == 'quarterly' ) {
        freezingPointLimit = 90;
    }
    if ( trim ( freezingPointCtrl.value ) == '' ) {
        errors = errors + "<li>Please enter value for Freezing Point</li>"
        freezingPointCtrl.select();
        freezingPointCtrl.focus();
    }
    if( !isInteger( freezingPointCtrl.value ) ) {
        errors = errors +"<li>Please enter a valid Number for Freezing Point";
        freezingPointCtrl.select();
        freezingPointCtrl.focus();
    } else if ( parseInt ( freezingPointCtrl.value, 10 ) <= 0 ) {
        errors = errors +"<li>Freezing Point should be greater than zero";
        freezingPointCtrl.select();
        freezingPointCtrl.focus();
    } if ( parseInt ( freezingPointCtrl.value, 10 ) > +freezingPointLimit ) {
        errors = errors +"<li>Freezing Point can not be greater than " + freezingPointLimit;
        freezingPointCtrl.select();
        freezingPointCtrl.focus();
    } if ( errors != "" ) {
        pa.innerHTML    = errors;
    } else {
        document.systemPreferencesForm.action.value = "save";
        document.systemPreferencesForm.submit();
    }
}

</script>

<!-- Top Header Start-->
<%@ include file="/jsp/includes/header.jsp" %>
<!-- Top Header End-->

<html:form action="/systemPreferences.do" name="systemPreferencesForm" type="com.scalar.forecast.systemprefs.forms.SystemPreferencesForm"  >

<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
    <TBODY>
    <TR>
        <td width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>
            <!-- Side Navigation start -->
            <%@ include file="/jsp/marketing/marketing_menu.jsp" %>
            <!-- end of the side navigations -->
        </td>


        <TD bgcolor="#ffffff"><IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
        <TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
        <TD valign="top" width="100%">
        <IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
        <BR>

        <center><span class="NArialW"><bean:message key="systemPreferences.head.title.preferences"/></span></center>

        <nested:nest property="systemPreferences">

        <nested:hidden property="systemPrefId" />

        <TABLE borderColor="#FFFFFF" width="85%" align=center border=0>

            <TR>
                <TD colspan=4>
                <% if ( !user1.isActionAllowed ( Functionality.SYSTEM_PREFERENCES,User.USER_ACTION_MODIFY ) ) { %>
                   <font class='NArialS'><font color='blue'><b><%=Constants.NO_MODIFY_RIGHTS %></b></font> <% } %>
                </TD>
            </TR>
            <TR><TD colspan='4' class="NArialL"><FONT id="errorsId"  color='FF0000'></FONT>
                <chiptrack:errors styleClass="NArialL" />
                <BR>
                <chiptrack:info styleClass="NArialL" />
                </TD>
            </TR>

            <TR  bgcolor='#DEE1E2'>
                <td width="25%" NOWRAP>
                    <font class="NArialL">
                        &nbsp;
                        <bean:message key="systemPreferences.label.pricePull" />
                    </font>
                </TD>
                <TD>
                    <font class="NArialL">
                        <logic:iterate name="priceTypes"  id="priceTypes" type="org.apache.struts.util.LabelValueBean" >
                            <nested:radio  property="priceType" value="<%=priceTypes.getValue()%>" styleClass="txfield"  />
                            <bean:write name="priceTypes" property="label"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        </logic:iterate>
                    </font>
                </td>
            </TR>



            <TR bgcolor='#FFFFEE'>
                <td width="25%" >
                    <font class="NArialL">
                        &nbsp;
                        <bean:message key="systemPreferences.label.partNumberType" />
                    </font>
                </TD>
                <TD>
                    <font class="NArialL">
                        <logic:iterate name="partNumberTypes"  id="partTypes"  type="org.apache.struts.util.LabelValueBean">
                            <nested:radio  property="partNumberType" value="<%=partTypes.getValue()%>"   styleClass="txfield"  />
                            <bean:write name="partTypes" property="label"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        </logic:iterate>
                    </font>
                </td>
            </TR>

            <%--<TR>
                <td width="25%" bgcolor='#DEE1E2'>
                    <font class="NArialL">
                        &nbsp;
                        <bean:message key="systemPreferences.label.canBuildMasterOverrideSFC" />&nbsp;&nbsp;&nbsp;&nbsp;
                        <logic:iterate name="buildMasterCantOverrideSFC"  id="buildMaster" type="org.apache.struts.util.LabelValueBean" >
                            <nested:radio  property="canBuildMasterCanOverrideSFC" value="<%=buildMaster.getValue()%>" styleClass="txfield"  />
                            <bean:write name="buildMaster" property="label"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            </logic:iterate>
                    </font>
                </td>
            </TR>--%>
            <nested:hidden property="canBuildMasterCanOverrideSFC"/>
            </nested:nest>
            <TR bgcolor='#DEE1E2'>
                <td width="25%" >
                    <font class="NArialL">
                        &nbsp;
                        Forecast Cycle
                   </font>
                </TD>
                <TD>
                    <font class="NArialL">
                        <nested:nest property="forecastTimeFrame">
                            <nested:select property="tfCycle" styleClass="txfield" >
                                <html:option value="weekly">Weekly</html:option>
                                <html:option value="monthly">Monthly</html:option>
                                <html:option value="quarterly">Quarterly</html:option>
                            </nested:select>
                        </nested:nest>
                    </font>
                </td>
            </TR>
            <TR bgcolor='#FFFFEE'>
                <td width="25%" >
                    <font class="NArialL">
                        &nbsp;
                        Freezing Point
                   </font>
                </TD>
                <TD>
                    <font class="NArialL">
                        <nested:nest property="forecastTimeFrame">
                            <nested:text property="tfCompany" styleClass="valuetxfield" size="3" maxlength="2"  onkeypress="javascript:allowInteger()" /> &nbsp;Days
                            <nested:hidden property="tfName" value="Month" />
                            <nested:hidden property="tfSelect" />
                            <nested:hidden property="tfMeasureType" value="Days"/>
                        </nested:nest>
                    </font>
                </td>
            </TR>

        </TABLE>



        <BR><BR>

        <table align="center">
        <TR>
            <td nowrap align='center' >
                <chiptrack:restrictedLink functionality='<%=Functionality.SYSTEM_PREFERENCES%>' action='<%=User.USER_ACTION_MODIFY%>' href="javascript:saveSystemPreferences();" onmouseover="window.status='Click to save system preferences';return true" onmouseout="window.status='';return true">
                    <img border="0" src="<%=chipTracContext%>/jsp/includes/images/save.gif" width="53" height="17"  onMouseOver="window.status='Click to add Sales Person';return true" onmouseout="window.status='';return true" title="Click to save system preferences">
                </chiptrack:restrictedLink>
            </td>
            <td>&nbsp;</td>
            <td nowrap align="center">
                <a href="javascript:document.systemPreferencesForm.reset()"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" width="53" height="17"  onMouseOver="window.status='Click  to Reset';return true" onmouseout="window.status='';return true" title="Click here to Reset"></a>
            </td>
        </TR>
        </table>


        <BR><BR><BR></TD>
        <TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
    </TR>
</TABLE>

<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->

<input type="hidden" name="action" >

</html:form>

</BODY>
</html:html>